#ifndef PHYSICSSUBSYSTEM_H
#define PHYSICSSUBSYSTEM_H

#include <SubSystemBase/ISubSystem.h>
#include <Logger/NullLogger.h>
#include <chipmunk/chipmunk.h>

#include <stdint.h>

class PhysicsSubSystem : public ISubSystem
{
public:

	static const char* SUBSYSTEMNAME;

	PhysicsSubSystem();
	virtual ~PhysicsSubSystem();

	/**
	 * Initializes the subsystem. If either an exception is thrown or the method returns false,
	 * the SubSystemManager will stop further initialization of subsystems, shutdown the
	 * already initialized subsystems and then the whole execution environment with error message.
	 * @throws Exception, possibly
	 * @return true, if the subsystem was successfully initialized, otherwise false
	 */
	virtual bool initialize();

	/**
	 * Releases subsystem-specific resources and shuts down the subsystem.
	 * Called by SubSystemManager when the execution environment is being shut down.
	 */
	virtual void shutdown();

	/**
	 * Returns is the subsystem initialized or not
	 * @return true, if the subsystem is initialized, otherwise false
	 */
	virtual	bool isInitialized() { return m_initialized;	}

	/**
	 * Changes the subsystem configuration to match given configuration.
	 * @throws InvalidConfigurationException, if the configuration isn't valid for this subsystem.
	 */
	//virtual void configure(IConfiguration& config) = 0;

	/**
	 * Returns the name of this subsystem as c-string (null-terminated char-array)
	 * @return Name of the subsystem
	 */
	virtual const char* getName() { return SUBSYSTEMNAME; }

	/**
	 * Sets the logger this subsystem should use
	 * @param logger	Logger to use
	 */
	//virtual void setLogger(ILogger& logger);

private:

	bool m_initialized;
	cpSpace *m_simulationSpace;
	static const int32_t m_iterations;
	static const int32_t m_elasticIterations;
};

#endif // PHYSICSSUBSYSTEM_H
